﻿namespace Standards.Web
{
    using System.Data.Entity;
    using System.Web;
    using System.Web.Http;
    using System.Web.Mvc;
    using System.Web.Optimization;
    using System.Web.Routing;

    using Standards.Data.EntityFramework;

    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801
    public class MvcApplication : HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            
            //Database.SetInitializer(new DropCreateDatabaseIfModelChanges<StandardsContext>());
            //Database.SetInitializer(new MigrateDatabaseToLatestVersion<StandardsContext, >());
            // TODO: have an initialise on the unit of work
            // Should never have to reference the context directly
            using (var context = new StandardsContext())
            {
                context.Database.Initialize(true);
            }
        }
    }
}